import { createApp } from '@vue/runtime-dom'
import { createStore } from 'vuex'
//数据持久化
import persistedState from 'vuex-persistedstate'

const modulesFiles = {
	'./modules/home.js': () => import('./modules/home.js'),
}
// const modulesFiles = import.meta.glob('./modules/*.js') //vite 批量导入用法  报错

const modules = {}
for (const key in modulesFiles) {
    modulesFiles[key]().then(res=>{
        modules[key.replace(/(\.\/modules\/|\.js)/g, '')] = res.default
    })
}

Object.keys(modules).forEach(item => {
    modules[item]['namespaced'] = true
})

export default createStore({
	plugins: [persistedState()],
    modules
})
